package io.nutz.nutzsite.module.sys.models;

import io.nutz.nutzsite.common.annotation.Excel;
import io.nutz.nutzsite.common.annotation.Excel.ColumnType;
import io.nutz.nutzsite.common.utils.excel.annotation.ExcelField;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

import javax.servlet.http.HttpSession;

import org.nutz.dao.entity.annotation.ColDefine;
import org.nutz.dao.entity.annotation.ColType;
import org.nutz.dao.entity.annotation.Column;
import org.nutz.dao.entity.annotation.Comment;
import org.nutz.dao.entity.annotation.Default;
import org.nutz.dao.entity.annotation.EL;
import org.nutz.dao.entity.annotation.ManyMany;
import org.nutz.dao.entity.annotation.Name;
import org.nutz.dao.entity.annotation.One;
import org.nutz.dao.entity.annotation.Prev;
import org.nutz.dao.entity.annotation.Table;
import org.nutz.plugins.validation.annotation.Validations;

/**
 * 用户信息
 * @author haiming
 */
@Table("sys_user")
public class User implements Serializable {
    private static final long serialVersionUID = 1L;

    @Name
    @Column
    @ColDefine(type = ColType.VARCHAR, width = 32)
    @Comment("登录账号")
    @ExcelField(title="登录账号")
    @Excel(name = "登录账号", cellType = ColumnType.STRING)
    @Validations(required=true,errorMsg = "登录账号不能为空")
    //@Prev(els = {@EL("uuid()")})
    private String id;

    /**
     * 部门ID
     */
    @Column("dept_id")
    @Comment("部门ID")
    @ExcelField(title="部门ID")
    @Validations(required=true,errorMsg = "部门不能为空")
    private String deptId;
    /**
     * 班级
     */
    @Column("classg")
    @Comment("班级")
    @ExcelField(title="班级")
    private String classg;
    /**
     * 部门父ID
     */
    private String parentId;

    /**
     * 用户名称
     */
    @Column("user_name")
    @Comment("用户姓名")
    @ExcelField(title="用户姓名")
    @Validations(required=true,errorMsg = "用户姓名不能为空")
    private String userName;

    /**
     * 密码
     */
    @Column("password")
    @Comment("密码")
    @Validations(required=true,errorMsg = "密码不能为空")
    @ExcelField(title="密码")
    private String password;
	/** 身份证号 */
@Column("cardid")
@Comment("身份证号")
@ExcelField(title="身份证号")
private String cardid;
    /**
     * 盐加密
     */
    @Column("salt")
    @Comment("盐加密")
    private String salt;

    /**
     * 用户邮箱
     */
    @Column("email")
    @Comment("用户邮箱")
    private String email;

    /**
     * 手机号码
     */
    @Column("phonenumber")
    @Comment("手机号码")
    private String phonenumber;

    /**
     * 用户性别
     */
    @Column
    @Comment("用户性别")
    private String gender;

    /**
     * 用户头像
     */
    @Column
    @Comment("用户头像")
    private String avatar;

    @One(field = "avatar")
    private Image image;

    /**
     * 帐号状态（0正常 1停用）
     */
    @Column
    @Comment("帐号状态（0正常 1停用） ")
    @Default("0")
    private boolean status;

    /**
     * 删除标志（0代表存在 1代表删除）
     */
    @Column("del_flag")
    @Comment("删除标记")
    @ColDefine(type = ColType.BOOLEAN)
    @Default("0")
    private boolean delFlag;

    /**
     * 最后登陆IP
     */
    @Column("login_ip")
    @Comment("最后登陆IP")
    private String loginIp;
    @Column("macaddr")
    @Comment("本机Mac")
    private String macaddr;
    /**
     * 最后登陆时间
     */
    @Column("login_date")
    @Comment("最后登陆时间")
    private Date loginDate;

    /**
     * 部门对象
     */
    @One(field = "deptId")
    private Dept dept;

    /**
     * 角色集合
     */
    @ManyMany(from = "user_id", relation = "sys_user_role", to = "role_id")
    private List<Role> roles;

    /**
     * 角色组
     */
    @ExcelField(title="角色")
    private String roleIds;

    /**
     * 岗位组
     */
    private String postIds;


	/** 是否公开源码 */
@Column("opensource")
@Comment("是否公开源码")
@Default("0")
private Boolean opensource;

	/** 解题数量 */
@Column("solved")
@Comment("AC题数")
@Default("0")
private Integer solved;

	/** 提交次数 */
@Column("submit")
@Comment("提交次数")
@Default("0")
private Integer submit;

	/** 比率 */
@Column("rating")
@Comment("比率")
@Default("0")
private Integer rating;

/**
 * 登录地点
 */
@Column("login_location")
@Comment("登录地点 ")
private String loginLocation;

/**
 * 浏览器类型
 */
@Column("browser")
@Comment("浏览器类型 ")
private String browser;

/**
 * 操作系统
 */
@Column("os")
@Comment("操作系统 ")
private String os;

@Column("userOnline")
@Comment("是否在线")
@ColDefine(type = ColType.BOOLEAN)
@Default("0")
private boolean userOnline;

@Column("sessionId")
@Comment("用户会话id ")
private String sessionId;

/**
 * session创建时间
 */
@Column("start_timestamp")
@Comment("session创建时间 ")
private Date startTimestamp;

/**
 * session最后访问时间
 */
@Column("last_access_time")
@Comment("session最后访问时间 ")
private Date lastAccessTime;

/**
 * 超时时间，单位为分钟
 */
@Column("expire_time")
@Comment("超时时间，单位为分钟 ")
private Long expireTime;

//标识由考点添加的考生
@Column("create_by")
@Comment("考点ID")
protected String createBy;

/** 备份的当前用户会话 */
/*private OnlineSession session;

public OnlineSession getSession() {
return session;
}

public void setSession(OnlineSession session) {
this.session = session;
}*/

private HttpSession session;

	public HttpSession getSession() {
	return session;
}

public void setSession(HttpSession session) {
	this.session = session;
}

	public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getDeptId() {
        return deptId;
    }

    public void setDeptId(String deptId) {
        this.deptId = deptId;
    }

    public String getParentId() {
        return parentId;
    }

    public void setParentId(String parentId) {
        this.parentId = parentId;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getSalt() {
        return salt;
    }

    public void setSalt(String salt) {
        this.salt = salt;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getPhonenumber() {
        return phonenumber;
    }

    public void setPhonenumber(String phonenumber) {
        this.phonenumber = phonenumber;
    }

    public String getGender() {
        return gender;
    }

    public void setGender(String gender) {
        this.gender = gender;
    }

    public String getAvatar() {
        return avatar;
    }

    public void setAvatar(String avatar) {
        this.avatar = avatar;
    }

    public boolean isStatus() {
        return status;
    }

    public void setStatus(boolean status) {
        this.status = status;
    }

    public boolean isDelFlag() {
        return delFlag;
    }

    public void setDelFlag(boolean delFlag) {
        this.delFlag = delFlag;
    }

    public String getLoginIp() {
        return loginIp;
    }

    public void setLoginIp(String loginIp) {
        this.loginIp = loginIp;
    }

    public Date getLoginDate() {
        return loginDate;
    }

    public void setLoginDate(Date loginDate) {
        this.loginDate = loginDate;
    }

    public Dept getDept() {
        return dept;
    }

    public void setDept(Dept dept) {
        this.dept = dept;
    }

    public List<Role> getRoles() {
        return roles;
    }

    public void setRoles(List<Role> roles) {
        this.roles = roles;
    }

    public String getRoleIds() {
        return roleIds;
    }

    public void setRoleIds(String roleIds) {
        this.roleIds = roleIds;
    }

    public String getPostIds() {
        return postIds;
    }

    public void setPostIds(String postIds) {
        this.postIds = postIds;
    }

    public Image getImage() {
        return image;
    }

    public void setImage(Image image) {
        this.image = image;
    }



	public String getCardid() {
		return cardid;
	}

	public void setCardid(String cardid) {
		this.cardid = cardid;
	}

	public Boolean getOpensource() {
		return opensource;
	}

	public void setOpensource(Boolean opensource) {
		this.opensource = opensource;
	}

	public Integer getSolved() {
		return solved;
	}

	public void setSolved(Integer solved) {
		this.solved = solved;
	}

	public Integer getSubmit() {
		return submit;
	}

	public void setSubmit(Integer submit) {
		this.submit = submit;
	}

	public Integer getRating() {
		return rating;
	}

	public void setRating(Integer rating) {
		this.rating = rating;
	}

	public static long getSerialversionuid() {
		return serialVersionUID;
	}

	public String getClassg() {
		return classg;
	}

	public void setClassg(String classg) {
		this.classg = classg;
	}

	public String getLoginLocation() {
		return loginLocation;
	}

	public void setLoginLocation(String loginLocation) {
		this.loginLocation = loginLocation;
	}

	public String getBrowser() {
		return browser;
	}

	public void setBrowser(String browser) {
		this.browser = browser;
	}

	public String getOs() {
		return os;
	}

	public void setOs(String os) {
		this.os = os;
	}

	public boolean isUserOnline() {
		return userOnline;
	}

	public void setUserOnline(boolean userOnline) {
		this.userOnline = userOnline;
	}

	public String getSessionId() {
		return sessionId;
	}

	public void setSessionId(String sessionId) {
		this.sessionId = sessionId;
	}

	public Date getStartTimestamp() {
		return startTimestamp;
	}

	public void setStartTimestamp(Date startTimestamp) {
		this.startTimestamp = startTimestamp;
	}

	public Date getLastAccessTime() {
		return lastAccessTime;
	}

	public void setLastAccessTime(Date lastAccessTime) {
		this.lastAccessTime = lastAccessTime;
	}

	public Long getExpireTime() {
		return expireTime;
	}

	public void setExpireTime(Long expireTime) {
		this.expireTime = expireTime;
	}

	public String getCreateBy() {
		return createBy;
	}

	public void setCreateBy(String createBy) {
		this.createBy = createBy;
	}

	public String getMacaddr() {
		return macaddr;
	}

	public void setMacaddr(String macaddr) {
		this.macaddr = macaddr;
	}
    
}
